var map, transfer_plans, start_marker, end_marker, station_markers = [],
transfer_lines = [],
walk_lines = [];

var mapInfo = {
		'nc':{
			locationLtd: 28.6993000000,	// 纬度
			locationLgd: 115.8688800000, //经度
			addressName:  '南昌-铜锣湾广场',
			addressInfo: '南昌市青山湖区庐山南大道369号',
			dateText: '8月25日-8月26日'
		},
		'nb': {
			locationLtd: 29.9150100000,	// 纬度
			locationLgd: 121.5298600000, //经度
			addressName:  '宁波-万达广场（江北店）',
			addressInfo: '宁波市江北区江北大道188号',
			dateText: '8月31日-9月2日'
		},
		'dl': {
			locationLtd: 39.0593900000,	// 纬度
			locationLgd: 121.7846200000, //经度
			addressName:  '大连-万达广场（开发区店）',
			addressInfo: '大连市辽河西路127号',
			dateText: '8月31日-9月2日'
		},
		'wh': {
			locationLtd: 30.5800800000,	// 纬度
			locationLgd: 114.2723700000, //经度
			addressName:  '武汉-武汉国际会展中心（广场）',
			addressInfo: '武汉市江汉区解放大道696号',
			dateText: '9月6日-9月8日'
		}
}

function getQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) return unescape(r[2]); return null;
}

function getCookie(name){ 
	var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
 
    if(arr=document.cookie.match(reg)){
    	return unescape(arr[2]); 
    } else {
    	return null; 
    }
 } 

function init() {
	var cityKey = getCookie('contestcity');
	var cityInfo = mapInfo[cityKey];
	var center=new qq.maps.LatLng(cityInfo.locationLtd, cityInfo.locationLgd);

	$('.js_addressname').html(cityInfo.addressName);
	$('#js_addressinfo').html(cityInfo.addressInfo);
	$('#js_date').html(cityInfo.dateText);
	// OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77
	$('#js_goaddress').on('click', function(){
		window.location.href = 'https://map.qq.com/nav/drive#routes/page?eword=' + cityInfo.addressName + '&epointx=' + cityInfo.locationLtd + '&epointy=' +  cityInfo.locationLgd + '&referer=myapp&key=&zoombutton=&trafficbutton=&rehttps=&_user_gps_track=&navimenu=&transport=&backurl='+ window.location.href +'&back=&footdetail=&graytest=&ref=&showSimunavi=&topbar=&sword=&spointy=&spointx=&dest=&start=';
	});
	map=new qq.maps.Map(document.getElementById("container"),{
		center:center,
		zoom:10
	});
	var label = new qq.maps.Label({
			position: center,
			map: map,
			content: cityInfo.addressName
	});
	//添加定时器
	setTimeout(function(){
		var marker=new qq.maps.Marker({
			position:center,
			animation:qq.maps.MarkerAnimation.DROP,
			map:map
		});
		//marker.setAnimation(qq.maps.Animation.DROP);
	},0);
}

window.onload =init;